#!/bin/sh
export PATH=/sbin:/bin:/usr/sbin:/usr/bin

mount -o nosuid,nodev,noexec,relatime -t proc proc /proc
#for mount utils
ln -sf /proc/self/mounts /etc/mtab
mount -o nosuid,nodev,noexec,relatime -t sysfs sysfs /sys

#-------------------------------------------------------------------------------
#mount /dev
mount -o exec,nosuid,relatime,size=10M,mode=0755 -t devtmpfs udev /dev
#syslog-ng is going amok, but still /dev/log is mandatory to many software
ln -sf null /dev/log

mkdir -m 0755 -p /dev/pts
mount -o relatime,gid=5,mode=0620 -t devpts devpts /dev/pts

mkdir -m 1777 -p /dev/shm
mount -o nosuid,nodev,noexec,relatime -t tmpfs shm /dev/shm
#-------------------------------------------------------------------------------

mount -o nosuid,nodev,relatime,mode=0755 -t tmpfs tmpfs /run

rm -Rf /tmp
mkdir /tmp
chmod 1777 /tmp
#set the default hostname in linux compilation
#hostname "amddev"

#-------------------------------------------------------------------------------
#mudev
modprobe unix
udevd --daemon

udevadm trigger --type=subsystems --action=add
udevadm trigger --type=devices --action=add

#those modules need /dev nodes
modprobe rtc-cmos

udevadm settle
#-------------------------------------------------------------------------------

#-------------------------------------------------------------------------------
#usb
modprobe ehci-hcd
modprobe ohci-hcd
modprobe usbhid
modprobe evdev
#-------------------------------------------------------------------------------

#-------------------------------------------------------------------------------
#network, could be NetworkManager (KLUDGE!), or a simple dhcp client, or IPv6
#autoconfiguration...
ip addr add 127.0.0.1/8 dev lo
ip addr add 192.168.1.5/24 dev eth0
ip link set dev lo up
ip link set dev eth0 up
ip route add default via 192.168.1.1 dev eth0
#-------------------------------------------------------------------------------

#-------------------------------------------------------------------------------
#CPUs
#BROKEN ON linux 3.15.3
#modprobe acpi-cpufreq
#modprobe cpufreq_ondemand
#cpufreq-set --cpu 0 --governor ondemand
#cpufreq-set --cpu 1 --governor ondemand
#-------------------------------------------------------------------------------

hwclock --utc --hctosys

#-------------------------------------------------------------------------------
#block scheduler, for a SSD drive, cfq I/O scheduler is useless
#modprobe cfq-iosched
#echo "cfq" > /sys/block/sda/queue/scheduler
#-------------------------------------------------------------------------------

#-------------------------------------------------------------------------------
##utmp/wtmp (I don't even use that stuff anymore, just for reference)
#: >/var/run/utmp
#chgrp utmp /var/run/utmp 2>/dev/null
#chmod 0664 /var/run/utmp
#if test ! -e /var/log/wtmp; then
#  : >/var/log/wtmp
#  chgrp utmp /var/log/wtmp 2>/dev/null
#  chmod 0664 /var/log/wtmp
#fi
#-------------------------------------------------------------------------------

#-------------------------------------------------------------------------------
#syslog-ng &
chronyd &
#/usr/libexec/fcron &
#/usr/sbin/sshd &
#-------------------------------------------------------------------------------
